<template>
  <div>
    <Dog
      v-for="(obj, index) in arr"
      :key="index"
      :imgurl="obj.dogImgUrl"
      :dogname="obj.dogName"
      @love='fn'
    ></Dog>
    <hr>
    <p>显示喜欢的狗</p>
    <ul>
      <li v-for="(item,index) in loveArr"  :key="index">{{item}} </li>
    </ul>
  </div>
</template>

<script>
import Dog from "./components/demo-02";
export default {
  data() {
    return {
      loveArr :[],
      arr: [
        {
          dogImgUrl:
            require("@/assets/1.jpg"),
          dogName: "博美",
        },
        {
          dogImgUrl:
             require("@/assets/2.jpg"),
          dogName: "泰迪",
        },
        {
          dogImgUrl:
            require("@/assets/3.jpg"),
          dogName: "金毛",
        },
        {
          dogImgUrl:
            require("@/assets/4.jpg"),
          dogName: "哈士奇",
        },
        {
          dogImgUrl:
            require("@/assets/5.jpg"),
          dogName: "阿拉斯加",
        },
        {
          dogImgUrl:
             require("@/assets/6.jpg"),
          dogName: "萨摩耶",
        },
      ],
    };
  },
  methods :{
    fn(dogName) {
      this.loveArr.push(dogName)
    }
  },
  components: {
    Dog,
  },
};
</script>

<style>

</style>